﻿using System;
using System.Data;
using HYElectricCommon;

namespace YArchitech.Revit.MEP.Calculator
{
	public class BuidingTypeClass
	{
		public static string BuidingType
		{
			get
			{
				return BuidingTypeClass.buidingType;
			}
			set
			{
				BuidingTypeClass.buidingType = value;
			}
		}

		public static DataBuidingType DataList1
		{
			get
			{
				return BuidingTypeClass.DataList;
			}
			set
			{
				BuidingTypeClass.DataList = value;
			}
		}

		public static bool GetDataToCreateRoom(string id)
		{
			string connStr = "Data Source=" + AssistFunc.GetAppRootPath() + "\\Data\\IlluminanceCal.db3;Initial Catalog=sqlite;Integrated Security=True;Max Pool Size=10";
			try
			{
				SqLiteHelper.SqlLiteDatabase(connStr);
			}
			catch (Exception)
			{
			}
			System.Data.DataTable dataTable = Database.ExecQuery(string.Format("select [BuildingType],[Place],[ReferencePlane],[PowerDensityNowV],[PowerDensityObjV],[IlluminanceStandard],[GlareValue],[Ra] from [IllAndPower] where [ID]='{0}'", id));
			if (dataTable == null)
			{
				return false;
			}
			if (dataTable.Rows.Count > 0)
			{
				try
				{
					DataRow dataRow = dataTable.Rows[0];
					BuidingTypeClass.BuidingType = dataRow["BuildingType"].ToString();
					BuidingTypeClass.DataList1 = new DataBuidingType(dataRow["place"].ToString(), dataRow["ReferencePlane"].ToString(), dataRow["PowerDensityNowV"].ToString(), dataRow["PowerDensityObjV"].ToString(), dataRow["IlluminanceStandard"].ToString(), dataRow["GlareValue"].ToString(), dataRow["Ra"].ToString(), id);
				}
				catch (Exception)
				{
					return false;
				}
				return true;
			}
			return false;
		}

		private static string buidingType;

		private static DataBuidingType DataList;
	}
}
